<div class="tmd-doc">
<p></p>
<h1 class="tmd-header-1">
function call 1
</h1>
<p></p>
<div id="question" class="tmd-base">
<p></p>
<div class="tmd-usual">
What is the behavior of the following program?
</div>
<p></p>
<pre class="tmd-code line-numbers">
<code class="language-go">package main

func f(vs ...interface{}) {
	print(len(vs))
}

func main() {
	f()
	f(nil)
	f(nil...)
}
</code></pre>
</div>
<p></p>
<div class="tmd-usual">
Choices:
</div>
<p></p>
<input type="radio" id="choiceA" name="choice" class="choice">
<input type="radio" id="choiceB" name="choice" class="choice">
<input type="radio" id="choiceC" name="choice" class="choice">
<input type="radio" id="choiceD" name="choice" class="choice">

<div id="choices">

<ul style="list-style-type:none;">
<li><label for="choiceA">It prints: 0 0 0.</label></li>
<li><label for="choiceB">It prints: 0 1 0.</label></li>
<li><label for="choiceC">It prints: 0 1 1.</label></li>
<li><label for="choiceD">It fails to compile.</label></li>
</ul>

</div><p></p>
<div id="answer" class="tmd-base">
<div class="tmd-usual">
Answer: It prints <code class="tmd-code-span">0 1 0</code>.
</div>
<p></p>
<div class="tmd-usual">
Run it on <a href="https://go.dev/play/p/5CW6f2UatfF">Go play</a>.
</div>
<p></p>
<div class="tmd-usual">
Key points:
</div>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
The <code class="tmd-code-span">nil</code> in <code class="tmd-code-span">f(nil...)</code> is treated as a nil slice (of type <code class="tmd-code-span">[]interface{}</code>).
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
The <code class="tmd-code-span">nil</code> in <code class="tmd-code-span">f(nil)</code> is treated as an element in a slice. The call <code class="tmd-code-span">f(nil)</code> is equivalent to <code class="tmd-code-span">f([]interface{}{nil}...)</code>.
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
The call <code class="tmd-code-span">f()</code> is equivalent to <code class="tmd-code-span">f(nil...)</code>.
</div>
</li>
</ul>
<p></p>
</div>
<p></p>
</div>
